var HuaZiGe = {
    name: 'huazi',
    age: 20,
    sex: 'boy',
    smock:function(){
        console.log('I am somking! cool!')
        //HuaZiGe.health--
        this.health--
    },
    drink:function(){
        console.log('I am drink')
        //HuaZiGe.health++
        this.health++
    },
    health:100
}

// HuaZiGe.health++ //可读可写
// console.log(HuaZiGe.health)//101

// HuaZiGe.smock()//99
// HuaZiGe.drink()//100
// HuaZiGe.drink()//101
// console.log(HuaZiGe.health)//101

// 增加
// HuaZiGe.boyFriend = 'lai'

// 查
// console.log(HuaZiGe.boyFriend)

// 改
// HuaZiGe.sex = 'girl'
// console.log(HuaZiGe.sex)

// 删除
delete HuaZiGe.name
console.log(HuaZiGe.naem)// undefined
console.log(HuaZiGe.like)
// 当访问一个不存在的变量时会把错，当访问一个对象不存在的属性就为undefinef

//对象的创建
//1. var obj = {} //plainObject 对象字面量 | 对象直接量
//2. 构造函数
     //1) 系统自带的构造函数 Object()
     //2) 自定义

//1)
// var obj = new Object() //var obj = {} 没有区别
// obj.name = '家君'
// obj.sex = 'boy'
// console.log(obj)

//2)
function Car(color){
    this.name = 'BMW'
    this.heigt = 1400
    this.lang = 4900
    this.weight = 1000
    this.health = 100
    this.run = function(){
       // health--//health is not defined
       this.health--
    }
    this.color = color
}
//console.log(Car())//undefined 构造函数没有返回值
var car1 = new Car('pink')
// car1.run()
// console.log(car1.health)//99
var car2 = new Car('red')
//console.log(car1===car2)//false 构造函数实例化出来的对象是相互独立的
// console.log(car1,car2)

car1.name = '红旗'
car2.name = '劳斯莱斯'
car2.run()
console.log(car1,car2)